$(document).ready(function(){
	$("#luckyTips").hide();
	$("#gift").hide();
	$("#gift").css({top:30+"%"});
	$("#shareBtn").hide();
})

//打开红包函数
function clickBag(){
	$("#luckyDraw").on("touchstart",function(e){	//点到红包时
		$("#redBag").addClass("redBagPlay");
		setTimeout(()=>{
			$("#round").addClass("roundPlay");
		},1500)
		setTimeout(()=>{
			$("#luckyDraw").css({backgroundImage:"url(./img/gift/gift_bg.jpg)"})
			$("#redLogo>img").css({top:85+"%"})
			$("#round").hide();
			$("#redBag").hide();
			$("#tips").hide();
			$("#shareBtn").show();
			$("#luckyTips").show();
			$("#gift").show();
			luckyDraw();
			share();
		},2500)
	})
}

//抽奖函数
function luckyDraw(){
	var giftNum=Math.ceil(Math.random()*100);
	console.log(giftNum)
	switch(giftNum){
		case 1:
			$("#gift>img").attr("src","img/gift/gift1.png");
			$("#tips2").html("价值3000元的腰间减肥仪");
			break;
		case 2:
			$("#gift>img").attr("src","img/gift/gift2.png");
			$("#tips2").html("价值300元的鸿运枕头");
			break;
		case 3:
			$("#gift>img").attr("src","img/gift/gift3.png");
			$("#tips2").html("价值200元的舒爽枕头");
			break;
		case 4:
			$("#gift>img").attr("src","img/gift/gift4.png");
			$("#tips2").html("价值600元的情侣枕头");
			break;
		case 5:
			$("#gift>img").attr("src","img/gift/gift5.png");
			$("#tips2").html("价值88元的护颈靠枕");
			break;
		case 6:
			$("#gift>img").attr("src","img/gift/gift6.png");
			$("#tips2").html("价值50元的赛诺红包");
			break;
		case 7:
			$("#gift>img").attr("src","img/gift/gift7.png");
			$("#tips2").html("价值1500元的舒爽清新薄垫");
			break;
		default:
			$("#gift>img").attr("src","img/gift/gift8.png");
			$("#gift").css({top:20+"%"});
			$("#tips1").html("就差一点点！");
			$("#tips2").html("");
			break;
	}
}


//邀请好友函数
function share(){
	var pn=location.search.split("?pn=")[1];
	$("#shareBtn").one("touchstart",function(){
		$("#myModal").modal('toggle');
		$("#myModal").one("touchstart",function(){
			window.location.href="userInfo.html?pn="+pn;
		})
	})
}

clickBag();